package com.heima.Controller;

import com.heima.Server.ArticleService;
import com.heima.model.Article.Dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewstoArticleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("app/article/api/v1/article")
public class ArticleController {

    @Autowired
    ArticleService articleService;

    //加载文章
    @PostMapping("/load")
    public ResponseResult Articleload(@RequestBody ArticleHomeDto articleHomeDto)
    {
        return articleService.ArticleLoad(articleHomeDto);
    }

    //上拉刷新
    @PostMapping("/loadnew")
    public ResponseResult Articleloadnew(@RequestBody ArticleHomeDto articleHomeDto)
    {
        return articleService.ArticleLoadnew(articleHomeDto);
    }

    //加载更多
    @PostMapping("/loadmore")
    public ResponseResult Articleloadmore(@RequestBody ArticleHomeDto articleHomeDto)
    {
        return articleService.ArticleLoadmore(articleHomeDto);
    }

//    保存文章
    @PostMapping("/save")
    public ResponseResult SaveArticle(@RequestBody WmNewstoArticleDto wmNewstoArticleDto)
    {
        return articleService.SaveArticle(wmNewstoArticleDto);
    }

//    文章下架
    @GetMapping("/down/{id}/{isDown}")
    public ResponseResult DwonArticle(@PathVariable Long id,@PathVariable Boolean isDown)
    {
        return articleService.DownOrUpArtiler(id,isDown);
    }
}
